PaiBazi <- function(year,month,day,hour){
  source('CmpShiShen.R',encoding = 'UTF-8')
  source('GenInfoTable.R',encoding = 'UTF-8')
  InfoTable <- GenInfoTable()
  
  # 拆成向量
  library(stringr)
  Bazi <- paste(year,month,day,hour,sep = '')
  MedV <- NULL
  for (i in 1:8) {
    MedV <- str_sub(Bazi,i,i) %>% c(MedV,.)
  }
  Bazi <- MedV
  
  # 十神计算
  MedV <- NULL
  for (i in 1:8) {
    if (mod(i,2) == 1 && i != 5){
      MedV <- rbind(MedV,data.frame(Bazi=Bazi[i],Cangzhi = Bazi[i],stringsAsFactors = FALSE))
    }else {
      for (j in 6:10) {
        if ((which(InfoTable[,j] == Bazi[i]) %>% length()) != 0){
          MedV <- rbind(MedV,data.frame(Bazi=Bazi[i],
                                        Cangzhi = InfoTable$Tiangan[InfoTable[,j] == Bazi[i]],
                                        stringsAsFactors = FALSE))
        }
      }
    }
  }
  rlt <- MedV[!is.na(MedV$Cangzhi),]
  rlt$body <- Bazi[5]
  
  rlt$syn <- NA
  for (i in 1:nrow(rlt)) {
    rlt$syn[i] <- CmpShiShen(rlt$Cangzhi[i],Bazi)
  }
  rlt$ShiShen <- str_sub(rlt$syn,7)
  return(rlt)
}